package com.louis.kitty.admin.service.impl;

import com.louis.kitty.admin.dao.SysUserTokenMapper;
import com.louis.kitty.admin.model.SysUserToken;
import com.louis.kitty.admin.service.SysUserTokenService;
import com.louis.kitty.core.page.MybatisPageHelper;
import com.louis.kitty.core.page.PageRequest;
import com.louis.kitty.core.page.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * ---------------------------
 * 用户Token (SysUserTokenServiceImpl)         
 * ---------------------------
 * 作者：  kitty-generator
 * 时间：  2019-05-07 17:16:16
 * 说明：  我是由代码生成器生生成的
 * ---------------------------
 */
@Service
public class SysUserTokenServiceImpl implements SysUserTokenService {

	@Autowired
	private SysUserTokenMapper sysUserTokenMapper;

	@Override
	public int save(SysUserToken record) {
		if(record.getId() == null || record.getId() == 0) {
			return sysUserTokenMapper.add(record);
		}
		return sysUserTokenMapper.update(record);
	}

	@Override
	public int delete(SysUserToken record) {
		return sysUserTokenMapper.delete(record.getId());
	}

	@Override
	public int delete(List<SysUserToken> records) {
		for(SysUserToken record:records) {
			delete(record);
		}
		return 1;
	}

	@Override
	public SysUserToken findById(Long id) {
		return sysUserTokenMapper.findById(id);
	}

	@Override
	public PageResult findPage(PageRequest pageRequest) {
		return MybatisPageHelper.findPage(pageRequest, sysUserTokenMapper);
	}
	
}
